home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1084 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: news.bridge.net!news
  2. From: David Byrden <100101.2547@compuserve.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Negative array-index ?
  5. Date: 9 Jan 1996 05:49:21 GMT
  6. Organization: self-employed
  7. Message-ID: <4csvl1$9gg@news.bridge.net>
  8. References: <30E9430C.4371B326@suse.de>
  9. NNTP-Posting-Host: ppp-mia1-58.bridge.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  14.  
  15.  
  16. Richard;
  17.  
  18. >>I have been trying to code some signal processing algorithms in C++. 
  19. >> For digital filters I need to access "negative" array-indices. It is 
  20. >> no problem to code this in an array-class (Everything below 0 is 0). 
  21. >> But the compiler always warns about an negative Index.
  22.  
  23. I don't quite understand what's happening. If you want an array with
  24. negative indices, just point a pointer into the middle of it;
  25.  
  26.  int array[100] ;
  27.  int* ptr = array + 50 ;
  28.  
  29.    ptr[-4]    // a valid int
  30.  
  31. Is this when your compiler gets snotty? If so, I guess that either 
  32. there is nothing you can do about it, or else the compiler will have some 
  33. means for you to selectively disable any desired warning message. 
  34. Certainly, it is a compiler-specific problem.
  35.  
  36.     David
  37.  
  38.  
  39.